import Layout from '@/views/layout/Layout';
import EmptyLayout from '@/views/layout/emptyLayout';

// 控制这系列页面的权限
const authData = {
  resource: ['medium:resource:', 'medium:platform:', 'medium:operator:', 'medium:dataEdit:', 'medium:dataShow:'], // 账号资源
  subcribe: ['crm:subcribe:read'], // 预约日历
  ConsultOrder: ['medium:sale:', 'medium:medium:'], // 询单

  commerceManage: ['crm:goodsList:read'], // 有赞商品
  mengliInventory: ['mengli:inventory:read', 'mengli:inventoryLog:read', 'mengli:skuLog:read', 'mengli:settleAccountsLog:read'], // 萌力库存
  mengliInventoryLog: ['mengli:inventoryLog:read'], // 入库记录
  skuLog: ['mengli:skuLog:read'], // SKU记录
  settleAccountsLog: ['mengli:settleAccountsLog:read'], // 结算记录

  mengliPlanet: ['mengli:list:read'], // 表情包
  mengliIpImage: ['mengli:ipImage:read'] // IP形象
};
let pageAllAuth = [];
for (const key in authData) {
  pageAllAuth = pageAllAuth.concat(authData[key]);
}

// 资源
const resourceRouter = [{
  path: '/resource',
  component: Layout,
  redirect: '/resource/resource',
  name: 'Medium',
  meta: { title: '资源', icon: 'sidebar-resource', authControl: pageAllAuth },
  children: [
    // 以下页面在侧边栏中会展示在 "账号" tab之下
    {
      path: 'resource',
      name: 'resource',
      parentName: '账号',
      component: () => import('@/views/resource/resource'),
      meta: { title: '账号资源', keepAlive: true, headerBarShow: false, authControl: authData.resource }
    },
    {
      path: 'subcribe',
      name: 'subcribe',
      parentName: '账号',
      component: () => import('@/views/subcribe/index'),
      meta: { title: '预约日历', headerBarShow: true, authControl: authData.subcribe }
    },
    // {
    //   path: 'order',
    //   name: 'ConsultOrder',
    //   parentName: '账号',
    //   component: () => import('@/views/medium/order'),
    //   meta: { title: '询单', isLayout: false, headerBarShow: true, authControl: authData.ConsultOrder }
    // },
    /**
     * 内页
     */
    /** 资源管理内页 */
    {
      path: 'resourcecreate',
      component: () => import('@/views/resource/create/index'),
      name: 'createResource',
      parentName: '账号',
      meta: { title: '新增资源', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/resource/resource' },
      hidden: true
    },
    {
      path: 'resourceedit/:resourceId',
      component: () => import('@/views/resource/create/index'),
      name: 'editResource',
      parentName: '账号',
      meta: { title: '编辑资源', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/resource/resource' },
      hidden: true
    },
    {
      path: 'resourcedetail/:resourceId',
      component: () => import('@/views/resource/detail/index'),
      name: 'detailResource',
      parentName: '账号',
      meta: { title: '资源详情', isSeal: false, keepAlive: false, headerBarShow: false, activeMenu: '/resource/resource' },
      hidden: true
    },
    {
      path: 'resourceupload',
      component: () => import('@/views/order/upload/index'),
      name: 'resourceupload',
      parentName: '账号',
      meta: { title: '文件上传', isSeal: false, keepAlive: false, headerBarShow: true, activeMenu: '/resource/resource' },
      hidden: true
    },
    /** 询单中心内页 */
    {
      path: 'order/detail/:id',
      hidden: true,
      name: 'ConsultOrderDetail',
      parentName: '账号',
      component: () => import('@/views/medium/orderDetail'),
      meta: { title: '询单中心', isLayout: false, headerBarShow: true, activeMenu: '/resource/resourceAccount/order' }
    },
    {
      path: 'ordercreate',
      component: () => import('@/views/order/create/batch'),
      name: 'createOrderBatch', // 批量增加订单
      parentName: '账号',
      meta: { title: '询单中心', isSeal: false, keepAlive: false, headerBarShow: true },
      hidden: true
    },
    // 以下页面在侧边栏中会展示在 "商品" tab之下

    {
      path: 'manage',
      name: 'commerceManage',
      parentName: '商品',
      component: () => import('@/views/commerce/productManage'),
      meta: { title: '有赞商品', keepAlive: false, headerBarShow: false, authControl: authData.commerceManage } // headerBarShow 为true显示头像
    },
    {
      path: 'inventory',
      name: 'mengliInventory',
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/index'),
      meta: {
        title: '萌力库存', headerBarShow: false, authControl: authData.mengliInventory, keepAlive: false, isChange: true
      }
    },
    {
      path: 'inventoryLog',
      name: 'mengliInventoryLog',
      hidden: true,
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/log'),
      meta: { title: '入库记录', headerBarShow: false, authControl: authData.mengliInventoryLog,
        keepAlive: false, isChange: true, activeMenu: '/resource/inventory'
      }
    },
    {
      path: 'skuLog',
      name: 'mengliSkuLog',
      hidden: true,
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/skuLog'),
      meta: { title: 'SKU记录', headerBarShow: false, authControl: authData.skuLog,
        keepAlive: false, isChange: true, activeMenu: '/resource/inventory'
      }
    },
    {
      path: 'settleAccountsLog',
      name: 'mengliSettleAccountsLog',
      hidden: true,
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/settleAccountsLog'),
      meta: { title: '结算记录', headerBarShow: false, authControl: authData.settleAccountsLog,
        keepAlive: false, isChange: true, activeMenu: '/resource/inventory'
      }
    },
    /**
   * 内页
   */
    /** 有赞商品内页 */
    {
      path: 'log',
      name: 'commerceLog',
      parentName: '商品',
      component: () => import('@/views/commerce/log'),
      hidden: true,
      meta: { title: '商品管理', keepAlive: false, headerBarShow: true, activeMenu: '/resource/manage' } // headerBarShow 为true显示头像
    },
    /** 萌力库存内页 */
    {
      path: 'inventory/create',
      name: 'mengliInventoryCreate',
      hidden: true,
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/create/index'),
      meta: { activeMenu: '/resource/inventory', title: ' 新建库存', headerBarShow: true }
    },
    {
      path: 'inventory/detail/:id',
      name: 'mengliInventoryDetail',
      hidden: true,
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/detail/index'),
      meta: { activeMenu: '/resource/inventory', title: ' 库存详情', headerBarShow: true }
    },
    {
      path: 'inventory/edit/:id',
      name: 'mengliInventoryEdit',
      hidden: true,
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/create/index'),
      meta: { activeMenu: '/resource/inventory', title: ' 编辑库存', headerBarShow: true }
    },
    {
      path: 'settleAccountsLog/detail/:id',
      name: 'mengliSettleAccountsDetail',
      hidden: true,
      parentName: '商品',
      component: () => import('@/views/mengliPlanet/inventoryManage/detail/module/detailSettleAccounts'),
      meta: { activeMenu: '/resource/inventory', title: ' 结算详情', headerBarShow: true }
    },

    {
      path: 'resourceEmoji',
      name: 'resourceEmoji',
      component: EmptyLayout,
      meta: { title: '表情', authControl: [...authData.mengliPlanet, ...authData.mengliIpImage] },
      children: [
        {
          path: 'index',
          name: 'mengliPlanet',
          component: () => import('@/views/mengliPlanet/index'),
          meta: { title: '表情包', headerBarShow: false, authControl: authData.mengliPlanet }
        },
        {
          path: 'ipImage',
          name: 'mengliIpImage',
          component: () => import('@/views/mengliPlanet/ipImage/index'),
          meta: { title: 'IP形象', keepAlive: false, headerBarShow: false, authControl: authData.mengliIpImage }
        },
        /**
         * 内页
         */
        /** 表情包内页 */
        {
          path: 'create',
          name: 'mengliCreate',
          hidden: true,
          component: () => import('@/views/mengliPlanet/create/index'),
          meta: { activeMenu: '/resource/resourceEmoji/index', title: ' 新建表情包', headerBarShow: true }
        },
        {
          path: 'ipEdit',
          name: 'mengliIpEdit',
          hidden: true,
          component: () => import('@/views/mengliPlanet/create/ipInfoEdit'),
          meta: { activeMenu: '/resource/resourceEmoji/index', title: '表情包管理', headerBarShow: true }
        },
        {
          path: 'detail/:id',
          name: 'mengliDetail',
          hidden: true,
          component: () => import('@/views/mengliPlanet/detail/index'),
          meta: { activeMenu: '/resource/resourceEmoji/index', title: ' 表情包管理', headerBarShow: true }
        },
        {
          path: 'edit',
          name: 'mengliEdit',
          hidden: true,
          component: () => import('@/views/mengliPlanet/create/index'),
          meta: { activeMenu: '/resource/resourceEmoji/index', title: ' 编辑表情包', headerBarShow: true }
        },
        /** ip形象内页 */
        {
          path: 'ipImageCreate',
          name: 'mengliIpImageCreate',
          hidden: true,
          component: () => import('@/views/mengliPlanet/create/index'),
          meta: { activeMenu: '/resource/resourceEmoji/ipImage', title: '新建IP形象', headerBarShow: true }
        },
        {
          path: 'ipImageEdit',
          name: 'mengliIpImageEdit',
          hidden: true,
          component: () => import('@/views/mengliPlanet/create/ipInfoEdit'),
          meta: { activeMenu: '/resource/resourceEmoji/ipImage', title: '编辑IP形象', headerBarShow: true }
        }
      ]
    }
  ]
}];
export default resourceRouter;
